package com.amazon.web.util;

import java.util.List;

public class ResponseUtil {
    private final static String SUCCESS="success";
    private final static String FAIL="fail";

    public static <T>  ApiListResponse  getSuccessResponse( List<T> data ,Integer total){
        ApiListResponse<List<T>> result = new ApiListResponse<>();
        result.setFlag(SUCCESS);
        result.setData(data);
        result.setTotal(total);
        return  result;
    }

    public static <T>  ApiResponse  getSuccessResponse( T data ,Integer total){
        ApiResponse<T> result = new ApiResponse<>();
        result.setFlag(SUCCESS);
        result.setData(data);
        result.setTotal(total);
        return  result;
    }

    public static <T>  ApiResponse  getSuccessResponse( T data ){
        ApiResponse<T> result = new ApiResponse<>();
        result.setFlag(SUCCESS);
        result.setData(data);
        result.setTotal(1);
        return  result;
    }

    public static  ApiResponse  getFailResponse( String msg ){
        ApiResponse result = new ApiResponse<>();
        result.setFlag(FAIL);
        result.setMessage(msg);
        return  result;
    }



}
